package com.yanqu.road.server.cmd.palace;

import com.yanqu.road.pb.estatewar.EstateWarProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.palace.CrossPalaceActivity;
import com.yanqu.road.server.manager.palace.CrossPalaceActivityMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.C_PALACE_USER_DATA_SYNC, desc = "玩家数据请求")
public class CrossPalaceUserDataSyncCmd extends CrossCommand {
    private long userId;
    private int activityId;
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        EstateWarProto.PalaceUserDataSyncReqMsg reqMsg = EstateWarProto.PalaceUserDataSyncReqMsg.parseFrom(packet.getBytes());
        activityId = reqMsg.getActivityId();
        userId = packet.getPlayerId();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        CrossPalaceActivity crossPalaceActivity = CrossPalaceActivityMgr.getCrossPalaceActivity(activityId);
        if(null != crossPalaceActivity){
            crossPalaceActivity.syncPalaceUserData(userId, serverId);
        }
    }

    @Override
    public void sendData() {

    }
}
